#ifndef _VECTOR4
#define _VECTOR4

// INCLUDES --------------------------------------------------------------------
#include "Base.h"

// DEFINES ---------------------------------------------------------------------

// TYPEDEFS --------------------------------------------------------------------
typedef struct
{
  union
  {
    fp x,y,z,w; // component style
    fp v[4];    // array style
  };
} Vector4; // 3D cartesian

// FUNCTIONS -------------------------------------------------------------------

/* GENERAL:
   d    -> destination
   s    -> source
   size -> array size (0,1 for single elements)

   a,b  -> two arbitrary vertices
   k    -> floating point scalar
*/
void Vector4Clear(Vector4 *v, ui32 size);                // clear to [0,0,0,1]
void Vector4Copy (Vector4 *d, Vector4 *s, ui32 size);    // clone vector src->dest

fp   Vector4Magnitude(Vector4 *v);                       // vector magnitude
void Vector4Normalize(Vector4 *v);                       // normalize to [0.0f, 1.0f]
void Vector4Invert   (Vector4 *v);                       // -(v)

fp   Vector4ScalarProduct(Vector4 *a, Vector4 *b);             // scalar product
void Vector4VectorProduct(Vector4 *d, Vector4 *a, Vector4 *b); // vector product

void Vector4Add  (Vector4 *d, Vector4 *a, Vector4 *b);   // +
void Vector4AddTo(Vector4 *d, Vector4 *a);               // +=

void Vector4Sub  (Vector4 *d, Vector4 *a, Vector4 *b);   // -
void Vector4SubTo(Vector4 *d, Vector4 *a);               // -=

void Vector4Mul  (Vector4 *d, Vector4* a, fp k);         // *
void Vector4MulTo(Vector4 *d, fp k);                     // *=

void Vector4Div  (Vector4 *d, Vector4* a, fp k);         // /
void Vector4DivTo(Vector4 *d, fp k);                     // /=

bool Vector4Equals  (Vector4 *a, Vector4 *b);            // ==
bool Vector4InEquals(Vector4 *a, Vector4 *b);            // !=

#endif // _VECTOR4
